<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>任务信息详情</title>
    {% load staticfiles %}
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="{% static 'lib/layui/css/layui.css' %}">
    <link rel="stylesheet" href="{% static 'css/scroll-bar.css' %}">
    <link rel="stylesheet" href="{% static 'css/sub-page.css' %}">

    <link rel="stylesheet" href="//at.alicdn.com/t/font_693759_wytlyqhtdtj1nhfr.css">
</head>
<body>
<div class="ok-body">
    <!--面包屑导航区域-->
    <div class="ok-body-breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>首页</cite></a>
                <a><cite>系统推送</cite></a>
                <a><cite>推送任务管理</cite></a>
				<a><cite>推送任务详细信息</cite></a>
            </span>
        <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);" title="重置">
            <i class="layui-icon layui-icon-refresh"></i>
        </a>
    </div>
    <!--form表单-->
    <form class="layui-form layui-form-pane ok-form" lay-filter="edit-task">

        <div class="layui-form-item" hidden>
            <label class="layui-form-label">ID</label>
            <div class="layui-input-block">
                <input type="text" name="id" autocomplete="off" disabled class="layui-input">
            </div>
        </div>

                    <div class="layui-form-item">
            <label class="layui-form-label">root密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" autocomplete="off" disabled  class="layui-input"
                       lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">hostname</label>
            <div class="layui-input-block">
                <input type="text" name="hostname" autocomplete="off" disabled class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">interface</label>
            <div class="layui-input-block">
                <input type="text" name="interface" disabled autocomplete="off"
                       class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">ip_address</label>
            <div class="layui-input-block">
                <input type="text" name="ip_address" autocomplete="off" disabled class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">netmask</label>
            <div class="layui-input-block">
                <input type="text" name="netmask" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">gateway</label>
            <div class="layui-input-block">
                <input type="text" name="gateway" autocomplete="off" disabled class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">DNS</label>
            <div class="layui-input-block">
                <input type="text" name="name_servers" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">MAC</label>
            <div class="layui-input-block">
                <input type="text" name="mac_address" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">kickstart</label>
                        <div class="layui-input-block">
                <input type="text" name="kickstart" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">profile</label>
                        <div class="layui-input-block">
                <input type="text" name="profile" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">总安装次数</label>
                        <div class="layui-input-block">
                <input type="text" name="installcount" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">安装成功数</label>
                        <div class="layui-input-block">
                <input type="text" name="successcount" autocomplete="off" disabled
                       class="layui-input"
                       lay-verify="required">
            </div>

        </div>

            <div class="layui-form-item">
            <label class="layui-form-label">网络启动</label>
            <div class="layui-input-block">
                <input type="checkbox" name="netboot_enabled"  disabled lay-skin="switch" lay-text="启用|禁用" checked value="0">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit">添加系统推送任务</button>
                {#                <button type="reset" class="layui-btn layui-btn-primary">重置</button>#}
            </div>
        </div>
    </form>
</div>
<!--js逻辑-->
<script src="{% static 'lib/layui/layui.js' %}"></script>
<script>
    var task = "{{ task }}";
    layui.use(['element', 'form', 'jquery', 'laydate','code'], function () {
        var element = layui.element
            , table = layui.table
            , form = layui.form
            , $ = layui.jquery
            , laydate = layui.laydate;
        layui.code({
            enconde :true,
            about : false,
            height: '460px' ,
            elem: 'textarea'
        });

        laydate.render({
            elem: '#birthday',
            type: "datetime"
        });


        form.on('submit(edit)', function (data) {

            console.log(data.field);

            $.ajax({
                type: 'post',
                url: "{% url 'api_init_system_task_run' %}", // ajax请求路径
                data: {
                    data: JSON.stringify(data.field),
                    csrfmiddlewaretoken: "{{ csrf_token }}",
                },
                dataType: 'json',
                success: function (data) {
                    if (data["status"] == 0) {
                        layer.msg(data["message"], {icon: 6, time: 1000, anim: 4}, function () {
                            {#window.location="{% url 'init-system-system' %}";#}
                            parent.layer.close(parent.layer.getFrameIndex(window.name));

                        });
                        {#window.location.href = "{% url 'init-system-system' %}";#}
                    } else {
                        layer.msg(data["message"]);
                    }
                }
            });
            return false;
        });


        $.ajax({
            type: 'post',
            url: "{% url 'api_init_system_task_get' %}", // ajax请求路径
            data: {
                data: JSON.stringify({'task': task}),
                csrfmiddlewaretoken: "{{ csrf_token }}",
            },
            dataType: 'json',
            success: function (data) {
                console.log(data);
                form.val('edit-task', data["data"][0]);
            }
        });


    })
</script>
</body>
</html>
</html>